package com.ydd.moudle.welcome;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.widget.RelativeLayout;

import com.ydd.R;
import com.ydd.base.BaseActivity;
import com.ydd.moudle.guide.GuideActivity;
import com.ydd.moudle.main.HomeActivity;
import com.ydd.util.db.SPManager;

/**
 * Created by tao on 17-3-20.
 */

public class WelcomeActivity extends BaseActivity {
    /**
     * UI
     */
    private RelativeLayout mAdLayout;
    private RelativeLayout mCopyLayout;
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (SPManager.getInstance().getBoolean(
                    SPManager.IS_SHOW_GUIDE, false)) {
                startActivity(new Intent(WelcomeActivity.this, HomeActivity.class));
            } else {
                SPManager.putBoolean(SPManager.IS_SHOW_GUIDE, true);
                startActivity(new Intent(WelcomeActivity.this, GuideActivity.class));
            }
            finish();
        }
    };

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome_layout);
        hidedenStatusBar();
        initView();
        mHandler.sendEmptyMessageDelayed(0, 3000);
    }

    private void initView() {
        mAdLayout = (RelativeLayout) findViewById(R.id.ad_content_view);
        mCopyLayout = (RelativeLayout) findViewById(R.id.content_layout);

        /**
         * 创建广告位
         */

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mHandler.removeCallbacksAndMessages(null);
    }
}
